const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    avatar_image:"",
    active:0,
    username:"",
    total_reward: 0,
    integral:"积分",

    list:[],
    total_page: 1,
    page: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    let language = wx.getStorageSync("langIndex");
    this.setData({
      language: language.en,
    });
   const value = wx.getStorageSync("integral");
    if (value) {
      this.setData({
        integral: value,
      });
    }
    this.get_data();

  },


  get_data(page = 1) {
    app._postNetWork({
      url:app.getNetAddresss("plugin.static-point-dividend.frontend.reward-log.getRewardList"),
      data:{page},
      success:async resdata=>{
        let {result,msg} = resdata.data;
        if(result){
          let {list,plugin_name,reward_summarize} = resdata.data.data;
          let _list = [];
          (page == 1)?(_list = list.data || []):(_list = this.data.list.concat(list.data));
          this.data.total_page = list.last_page;
          this.data.page = list.current_page;
          this.setData({
            list:_list,
            username:reward_summarize.member_info.username,
            avatar_image:reward_summarize.member_info.avatar_image,
            total_reward:reward_summarize.total_reward,
          })
          wx.setNavigationBarTitle({
            title:plugin_name,
          })
        }else{
          app.tips(msg);
        }
      }
    })

  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
      if(this.data.page>=this.data.total_page){
        return false;
      }
      let page = this.data.page + 1;
      this.get_data(page)

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
